Skip to content

Handle inline PEM keys with removed line endings#1804

Draft
Copilot wants to merge 8 commits into
developfrom
copilot/fix-threading-issue-in-channel
Draft

Handle inline PEM keys with removed line endings#1804
Copilot wants to merge 8 commits into
developfrom
copilot/fix-threading-issue-in-channel

Conversation

Copilot AI commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

The inline PEM test was normalizing line endings with an incomplete pattern and only covering space-separated output. This change corrects the line-ending handling in the test and teaches PrivateKeyFile to accept PEM content whose line breaks have been removed entirely.

  • Test coverage

    • Replace line endings with string.Empty instead of a space to exercise the stricter inline PEM case.
    • Update the test name to reflect line-ending removal rather than space separation.
    • Simplify the line-ending regex to cover CRLF, CR, and LF in one expression.
  • PEM parsing

    • Keep the existing multiline PEM parser unchanged for normal files.
    • Add a narrow inline-PEM normalization path that only applies when the input has no line breaks and matches BEGIN ... END with contiguous base64 payload.
    • Reconstruct the minimal newline-delimited form before applying the existing PEM regex, avoiding broader whitespace acceptance in the payload.
var inlinePem = Regex.Replace(original, @"\r\n?|\n", string.Empty).Trim();
var pkFile = new PrivateKeyFile(new MemoryStream(Encoding.UTF8.GetBytes(inlinePem)), passPhrase);

Copilot AI changed the title Support inline PEM private keys where newlines were replaced by spaces (CI/CD injection) Support inline PEM private keys (newlines replaced by spaces by CI/CD injection) Jun 13, 2026
Copilot AI requested a review from Rob-Hague June 13, 2026 15:37
Copilot AI changed the title Support inline PEM private keys (newlines replaced by spaces by CI/CD injection) Permit \r, \n, \t and space after PEM encapsulation boundary in PrivateKeyPattern Jun 13, 2026
Copilot AI changed the title Permit \r, \n, \t and space after PEM encapsulation boundary in PrivateKeyPattern Relax PEM private key regex to accept unchunked base64 payloads Jun 23, 2026
Copilot AI changed the title Relax PEM private key regex to accept unchunked base64 payloads Handle inline PEM keys with removed line endings Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants